/**
 * 判断是否在微信浏览器中打开
 * @returns boolean
 */
export function isWeixinBrowser() {
  const ua = navigator.userAgent.toLowerCase();
  return ua.indexOf("micromessenger") !== -1 && !!window.wx;
}

/**
 * 判断是否在特来电App浏览器中打开
 * @returns boolean
 */
export function isTeldAppBrowser() {
  return !!window.TeldApi;
}

/**
 * 获取运行环境
 * @returns "TeldApp"|"WX"|"H5"
 */
export function getRunEnvironment() {
  if (isTeldAppBrowser()) {
    return "TeldApp";
  } if (isWeixinBrowser()) {
    return "WX";
  }
  return "H5";
}
